﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage/Edit.Master"  AutoEventWireup="true" ValidateRequest="false" CodeBehind="ContractEdit_ToDatabase.aspx.cs" Inherits="Honestysoft.Financing.WebUI.Module.Contract.ContractEdit_ToDatabase"  %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../../Styles/tab/tab.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript" src="../../Styles/tab/tab.js"></script>
	<script language="javascript" type="text/javascript" src="../../Apply/SelectOu.js"></script>
    <script language="javascript" type="text/javascript" src="../../Scripts/control.js"></script>
	<script language="javascript" type="text/javascript">
	    function SelectContractor() {
	        var retValue = SelectOu('<%=Honestysoft.Baseframework.WebUI.Globals.Home %>', '<%=((int)Honestysoft.Baseframework.Model.EnumItem.OuSelectViewStyle.Style2).ToString() %>', '<%=((int)Honestysoft.Baseframework.Model.EnumItem.OuSelectMode.Single).ToString() %>', '<%=((int)Honestysoft.Baseframework.Model.EnumItem.OuSelectTarget.Outer).ToString() %>', '<%=((int)Honestysoft.Baseframework.Model.EnumItem.OuSelectNodeType.Company).ToString() %>', '<%=txtContractor.ClientID %>', '<%=hidContractor.ClientID %>');
	        return false;
	    }
	    function SelectDBankCompany() {
	        var retValue = SelectOu('<%=Honestysoft.Baseframework.WebUI.Globals.Home %>', '<%=((int)Honestysoft.Baseframework.Model.EnumItem.OuSelectViewStyle.Style2).ToString() %>', '<%=((int)Honestysoft.Baseframework.Model.EnumItem.OuSelectMode.Single).ToString() %>', '<%=((int)Honestysoft.Baseframework.Model.EnumItem.OuSelectTarget.Outer).ToString() %>', '<%=((int)Honestysoft.Baseframework.Model.EnumItem.OuSelectNodeType.Company).ToString() %>', '<%=txtDBankCompany.ClientID %>', '<%=hidDBankCompany.ClientID %>');
	        return false;
	    }
	    function ClearDBankCompany() {
	        document.getElementById('<%=txtDBankCompany.ClientID %>').value = "";
	        document.getElementById('<%=hidDBankCompany.ClientID %>').value = "";
	    }
	    function doConfirm() {
	        var arrId = new Array();
	        arrId[0] = '<%=Request["ID"]+"" %>';
	        var retValue = window.showModalDialog('ContractConfirm.aspx', arrId, 'dialogHeight=500px;dialogWidth=560px;help=no;scrollbars=no;status=no');
	        if (typeof (retValue) != "undefined" && retValue != null && retValue) {
	            return true;
	        }
	        return false;
	    }
	    function viewConfirm() {
	        var arrId = new Array();
	        arrId[0] = '<%=Request["ID"]+"" %>';
	        var retValue = window.showModalDialog('ContractConfirm.aspx', arrId, 'dialogHeight=500px;dialogWidth=560px;help=no;scrollbars=no;status=no');
	        return false;
	    }
	    function formatAccount() {
	        var val = document.getElementById("<%=txtBankAccount.ClientID %>").value;	        
	        var reg = /\s{1,}/g;
	        var val_ = "";
	        //去除空格 
	        val = val.replace(reg, "");
	        var len = val.length;
	        for (var i = 0; i < len; i++) {
	            if ((i+1) % 4 == 0) {
	                val_ = val_ + val.charAt(i) + " ";
	            }
	            else {
	                val_ = val_ + val.charAt(i);
	            }
	        }
	        document.getElementById("<%=txtBankAccount.ClientID %>").value = val_;
	    }
	    function checkSave() {
	        if (document.getElementById("<%=txtCode.ClientID %>").value == "") {
	            alert("请输入合同编号！");
	            return false;
	        }
	        if (document.getElementById("<%=txtName.ClientID %>").value == "") {
	            alert("请输入合同名称！");
	            return false;
	        }
	        if (document.getElementById("<%=numTotalPrice.ClientID %>").value == "") {
	            alert("请输入合同总价！");
	            return false;
	        }
	        if (document.getElementById("<%=txtContractor.ClientID %>").value == "") {
	            alert("请输入施工单位！");
	            return false;
	        }
	        if (document.getElementById("<%=txtBankName.ClientID %>").value == "") {
	            alert("请输入开户银行！");
	            return false;
	        }
	        if (document.getElementById("<%=txtBankAccount.ClientID %>").value == "") {
	            alert("请输入收款账号！");
	            return false;
	        }
	        return true;
	    }
	    function openwindow(url, name) {
	        var iWidth = 940; //弹出窗口的宽度;
	        var iHeight = window.screen.availHeight - 30; //弹出窗口的高度;
	        var iTop = (window.screen.availHeight - 30 - iHeight) / 2; //获得窗口的垂直位置;
	        var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
	        window.open(url, name, 'height=' + iHeight + ',innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',toolbar=no,menubar=no,scrollbars=yes,resizeable=no,location=no,status=no');
	    }
    </script>
<script language="javascript" type="text/javascript">
    var opts = null;
    function InitRules() {
    }
//        function InitRules() {
//            opts = {
//                 rules:
//                 {
//					<%= txtProject.UniqueID%>:{required: true},
//					<%= ddlContractCategory.UniqueID%>:{required: true},
//					<%= txtCode.UniqueID%>:{required: true,minlength:3,maxlength: 3},
//					<%= txtName.UniqueID%>:{required: true,maxlength: 200},
//					<%= numTotalPrice.UniqueID%>:{required: true,number: true},
//					<%= txtContractor.UniqueID%>:{required: true},
//                    <%= txtBankName.UniqueID%>:{required: true,maxlength: 200},	
//                    <%= txtBankAccount.UniqueID%>:{required: true,maxlength: 200}				
//                 },
//                 messages:
//                 {
//					<%= txtProject.UniqueID%>:{required: "所属项目 请选址合适的值"},
//					<%= ddlContractCategory.UniqueID%>:{required: "合同类别 请选择合适的值"},
//					<%= txtCode.UniqueID%>:{required: "合同编号 请输入合适的值",minlength:"合同编号 最少需要输入3个字符",maxlength: "合同编号 最多只能输入3个字符"},
//					<%= txtName.UniqueID%>:{required: "合同名称 请输入合适的值",maxlength: "合同名称 最多只能输入200个字符"},
//					<%= numTotalPrice.UniqueID%>:{required: "合同总价 请输入合适的值",number: "合同总价 请输入有效的数字"},
//					<%= txtContractor.UniqueID%>:{required: "施工单位 请输入合适的值"},
//                    <%= txtBankName.UniqueID%>:{required:  "开户银行 请输入合适的值",maxlength: "开户银行 最多只能输入200个字符"},	
//                    <%= txtBankAccount.UniqueID%>:{required:  "收款账号 请输入合适的值",maxlength: "收款账号 最多只能输入200个字符"}					
//                 },
//                 onfocusout:false,
//                 onclick:false,
//                 onkeyup:false,
//                 errorPlacement: function(error, element) {
//                    $("#errorContainer").show();
//                    error.html("<li>* "+error.html()+"</li>");
//                    error.appendTo("#errorContainer");
//                 },
//                 wrapper:"li"
//            }
    //        }


    function getLikeContractByName(val) {
        if ($.trim(val) != "") {
            $.ajax({
                type: "POST",
                url: '../Audit/JSON/GetLikeContract.ashx?val=' + escape(val) + '&type=0&randID=' + escape(new Date()),
                success: function (msg) {
                    if (msg != '') {
                        alert("系统检测到可能存在相同的合同，点击确定弹出检测结果，请仔细检查！")
                        window.showModalDialog('GetContractLike.aspx?val=' + escape(val) + '&type=0&randID=' + escape(new Date()), window, 'dialogHeight=300px;dialogWidth=450px;help=no;scrollbars=no;status=no');
                        return false;
                    }
                }
            });
        }
    }
    function getLikeContractByPrice(val) {
        if ($.trim(val) != "") {
            $.ajax({
                type: "POST",
                url: '../Audit/JSON/GetLikeContract.ashx?val=' + val + '&type=1&randID=' + escape(new Date()),
                success: function (msg) {
                    if (msg != '') {
                        alert("系统检测到可能存在相同的合同，点击确定弹出检测结果，请仔细检查！")
                        window.showModalDialog('GetContractLike.aspx?val=' + val + '&type=1&randID=' + escape(new Date()), window, 'dialogHeight=300px;dialogWidth=450px;help=no;scrollbars=no;status=no');
                        return false;
                    }
                }
            });
        }
    }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
       <div class="nTab_l">
        <div class="TabTitle_l">
            <ul id="myTab_l">     
                <li id='li0' class="active" onclick="nTabs(this,0);" style="padding-left:0px;" >基本信息</li>
                <li id='li1' class="normal" onclick="nTabs(this,1);" style="padding-left:0px;" >变更记录</li> 
                <li id='li2' class="normal" onclick="nTabs(this,2);" style="padding-left:0px;" >资金信息</li> 
            </ul>
        </div>
        <div class="TabContent_l" style="height:470px;overflow-y:scroll;overflow-x:hidden">
		<div id="myTab_l_Content0"  style="width:96%;padding-top:8px">
            
        <table cellpadding="0" width="100%" cellspacing="0" border="1" class="tEdit">
          <tr style="display:none">
            <td style="width:120px;" ></td><td></td><td style="width:120px;" ></td><td></td>
          </tr>
		<tr>
			<td class="title1">所属项目<span class="req">﹡</span></td>
			<td colspan="3">
            <asp:TextBox ID="txtProject" runat="server" ReadOnly="true"  cssClass="input2" MaxLength="36" Width="98%"></asp:TextBox></td>
			
		</tr>
		<tr>
            <td class="title1" >合同编号<span class="req">﹡</span></td>
			<td><asp:Label runat="server" ID="lblFCode"></asp:Label>
            <asp:TextBox ID="txtCode" runat="server" onbeforepaste="numboxPaste();" onkeypress="isDecimal();"  cssClass="input2" MaxLength="3"></asp:TextBox></td>
            <td class="title1" >合同类别<span class="req">﹡</span></td>
			<td><asp:DropDownList ID="ddlContractCategory" runat="server" cssClass="input2"  Width="98%"></asp:DropDownList></td>
			
		</tr>
        <tr>
            <td class="title1">合同名称<span class="req">﹡</span></td>
			<td colspan="3"><asp:TextBox ID="txtName"  runat="server"  cssClass="input2" MaxLength="200" Width="98%"></asp:TextBox></td>
        </tr>
		<tr>
			<td class="title1">合同总价(元)<span class="req">﹡</span></td>
			<td><asp:TextBox ID="numTotalPrice" runat="server"  cssClass="input2" onbeforepaste="numboxPaste();" onkeypress="isDecimal();" Width="96%"></asp:TextBox></td>
			<td class="title1">签订日期</td>
			<td><asp:TextBox ID="dtpSignDate" runat="server" cssClass="input2" onfocus="setday(this);" Width="96%"></asp:TextBox></td>
		
		</tr>   
		<tr>
			<td class="title1">施工单位<span class="req">﹡</span></td>
			<td colspan="3"><asp:TextBox ID="txtContractor" runat="server" ReadOnly="true"  cssClass="input2" MaxLength="36" Width="86%"></asp:TextBox>
            <asp:HiddenField ID="hidContractor" runat="server" />
                <asp:Button runat="server" ID="btnSelect2" Text="选择" OnClientClick="SelectContractor();return false;" class="btn_small_normal" 
                onmouseover="this.className='btn_small_active'" 
                onmouseout="this.className='btn_small_normal'" />
            </td>
		</tr>
        <tr>
			<td class="title1">委托收款单位</td>
			<td colspan="3"><asp:TextBox ID="txtDBankCompany" runat="server" cssClass="input2"  Width="86%"></asp:TextBox>
            <asp:HiddenField ID="hidDBankCompany" runat="server" />
                <asp:Button runat="server" ID="Button1" Text="选择" OnClientClick="SelectDBankCompany();return false;" class="btn_small_normal" 
                onmouseover="this.className='btn_small_active'" 
                onmouseout="this.className='btn_small_normal'" />
                <asp:Button runat="server" ID="Button2" Text="清除" OnClientClick="ClearDBankCompany();return false;" class="btn_small_normal" 
                onmouseover="this.className='btn_small_active'" 
                onmouseout="this.className='btn_small_normal'" />
            </td>
		</tr>
        <tr>
            <td class="title1">开户银行<span class="req">﹡</span></td><td><asp:TextBox runat="server" ID="txtBankName" MaxLength="200" cssClass="input2" Width="96%"></asp:TextBox> </td>
            <td class="title1">收款账号<span class="req">﹡</span></td><td><asp:TextBox runat="server" ID="txtBankAccount" onchange="formatAccount();" MaxLength="200" cssClass="input2"  Width="96%"></asp:TextBox></td>
        </tr>
        
        <tr>
            <td class="title1">项目委托代建单位</td>
			<td colspan="3">
                <table cellpadding="0" width="100%" cellspacing="0" border="1" class="t1" id="Table2">
		            <thead>  
                        <th align="center" width="30px">
                            <input type="checkbox" name="chkAll" value="checkbox" onclick='javascript:checkAll(this,"chkID")' />
                        </th>
                        <th align="center">单位名称</th>
                    </thead>
                    <asp:Repeater runat="server" ID="rptDOwnerList">
			            <ItemTemplate>
				            <tr>
					            <td align="center" >
                                    <input type="checkbox" name="chkID" id="chk<%# DataBinder.Eval(Container.DataItem,"CompanyID") %>"  value="<%# DataBinder.Eval(Container.DataItem,"CompanyID") %>" <%# GetIsChecked(DataBinder.Eval(Container.DataItem,"IsChecked")) %>  >
					            </td>
					            <td style="text-align:left"><%#  DataBinder.Eval(Container.DataItem,"CompanyName") %></td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
            </td>
        </tr>
        <tr>
            <td class="title1">付款条件</td>
            <td colspan="3">
            <FCKeditorV2:FCKeditor ID="FCKeditor2" BasePath="../../fckeditor/" ToolbarSet="Custom3" runat="server" Width="630px" Height="250px">
            </FCKeditorV2:FCKeditor>
            </td>
        </tr>
		<tr>
			<td class="title1">备注</td>
			<td colspan="3"><asp:TextBox ID="txtRemark" runat="server"  cssClass="input2" TextMode="MultiLine" Rows="10" Width="98%"></asp:TextBox></td>			
		</tr>
        </table>
        
        
        </div>
        <div id="myTab_l_Content1" class="none" style="height:100%;overflow-y:hidden" align="center">
			
            <div style="height:10px">&nbsp;
           
    </div>
            
    <table cellpadding="0" width="100%" cellspacing="0" border="1" class="t1" id="tGrid">
		<thead>  
            <th align="center">变更前金额</th>
            <th align="center">变更后金额</th>
            <th align="center" width="90px">登记人</th>
            <th align="center" width="120px">登记时间</th>
      	</thead>           
		<asp:Repeater runat="server" ID="rptList">
			<ItemTemplate>
				<tr>				
					<td align="right"><%# string.Format("{0:N}", DataBinder.Eval(Container.DataItem,"SourceMoney")) %></td>
					<td align="right"><%# string.Format("{0:N}",  DataBinder.Eval(Container.DataItem,"ChangeMoney")) %></td>
					<td><%#  DataBinder.Eval(Container.DataItem,"SponsorName") %></td>
					<td><%#  DataBinder.Eval(Container.DataItem,"CreateTime") %></td>
				</tr>  
			</ItemTemplate>
		</asp:Repeater>
    </table>

		</div>
         <div id="myTab_l_Content2" class="none" style="height:100%;overflow-y:hidden" align="center">
			
            <div style="height:10px">&nbsp;
           
    </div>
            
    <table cellpadding="0" width="100%" cellspacing="0" border="1" class="t1" id="Table1">
		<thead>  
            <th align="center">作业表单号</th>
            <th align="center" width="80px">批次</th>
            <th align="center" width="80px">初审日期</th>
            <th align="center" width="100px">初审金额</th>
            <th align="center" width="80px">放款日期</th>
            <th align="center" width="100px">放款金额</th>
            <th align="center" width="80px">实拨日期</th>
            <th align="center" width="100px">实拨金额</th>
      	</thead>           
		<asp:Repeater runat="server" ID="repATList">
			<ItemTemplate>
				<tr>
                    <td>
                    <a href='#' onclick="javascript:openwindow('../Audit/AuditTable_Edit.aspx?ID=<%# DataBinder.Eval(Container.DataItem,"ID") %>&FunctionID=<%=Request["FunctionID"] %>','');" ><%# DataBinder.Eval(Container.DataItem,"Code") %></a>
                    </td>	
                    <td><%# DataBinder.Eval(Container.DataItem,"BatchNo") %></td>	
                    <td><%# string.Format("{0:yyyy-MM-dd}", DataBinder.Eval(Container.DataItem,"FirstDate")) %></td>				
					<td align="right"><%# string.Format("{0:N}", DataBinder.Eval(Container.DataItem,"Amount_S")) %></td>
                    <td><%# string.Format("{0:yyyy-MM-dd}", DataBinder.Eval(Container.DataItem,"GiveDate")) %></td>	
					<td align="right"><%# string.Format("{0:N}", DataBinder.Eval(Container.DataItem,"GiveAmount")) %></td>
                    <td><%# string.Format("{0:yyyy-MM-dd}", DataBinder.Eval(Container.DataItem,"BFDate")) %></td>	
					<td align="right"><%# string.Format("{0:N}", DataBinder.Eval(Container.DataItem,"BFAmount")) %></td>
				</tr>  
			</ItemTemplate>
		</asp:Repeater>
        <tr class="a1">
            <td>合计金额</td>	
            <td></td>	<td></td>				
			<td align="right"><asp:Label runat="server" ID="lblAmount_S"></asp:Label></td>
            <td></td>	
            <td align="right"><asp:Label runat="server" ID="lblGiveAmount"></asp:Label></td>	
            <td></td>	
            <td align="right"><asp:Label runat="server" ID="lblBFAmount"></asp:Label></td>	
        </tr>
        <tr class="a1">
            <td>支付比例</td>	
            <td></td>				<td></td>	
			<td align="right"><asp:Label runat="server" ID="lblPP_Amount_S"></asp:Label></td>
            <td></td>	
            <td align="right"><asp:Label runat="server" ID="lblPP_GiveAmount"></asp:Label></td>	
            <td></td>	
            <td align="right"><asp:Label runat="server" ID="lblPP_BFAmount"></asp:Label></td>	
        </tr>
    </table>

		</div>
        </div>
        </div>
        <div style="height:8px">&nbsp;</div>
<div class="save_area">
            <asp:Button runat="server" ID="btnOK" Text="确定" class="btn_normal" 
                onmouseover="this.className='btn_active'"  OnClientClick="return checkSave();"
                onmouseout="this.className='btn_normal'" onclick="btnOK_Click"/>
            <input type="button" id="btnExit" value="取消" onclick="javascript:window.returnValue=false;window.close();" class="btn_normal" onmouseover="this.className='btn_active'" onmouseout="this.className='btn_normal'" />
        </div>
</asp:Content>


